package br.fatec.servico;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class OracleSQLDAOFactory extends DAOFactory {

	private static String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
	private static String DATABASE_URL = "jdbc:oracle:thin:@localhost/xe";
	private static String LOGIN = "system";
	private static String PASSWORD = "271286";
	private static Connection conexao;

	public static Connection criaConexao() {
		// SOCKET DE CONEXAO
		conexao = null;
		try {
			if (conexao == null || conexao.isClosed()) {
				Class.forName(JDBC_DRIVER);
				// ESTABELECE A CONEXAO COM O BANCO DE DADOS
				conexao = DriverManager.getConnection(DATABASE_URL, LOGIN,
						PASSWORD);
			}
		} catch (ClassNotFoundException cnfex) {
			// EXCESSOES PARA DRIVER DE CONEXAO NAO ENCONTRADO SAO TRATADOS AQUI
			cnfex.printStackTrace();
		} catch (SQLException sqlex) {
			// EXCESSOES DO ESL SAO TRATADAS AQUI
			sqlex.printStackTrace();
		} catch (Exception ex) {
			// process remaining Exceptions here
			ex.printStackTrace();
		}

		return conexao;
	}

	@Override
	public IEmpresaDAO getEmpresaDAO() {
		return new OracleSQLEmpresaDAO();
	}

	@Override
	public IUsuarioDAO getUsuarioDAO() {
		// return new OracleSQLUsuarioDAO();
		return null;
	}

	@Override
	public IResponsavelDAO getResponsavelDAO() {
		// return new OracleSQLResponsavelDAO();
		return null;
	}

	@Override
	public IConvenioDAO getConvenioDAO() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public IEstagioDAO getEstagioDAO() {
		// TODO Auto-generated method stub
		return null;
	}

}
